import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/JwtAPI/AuthAsync/AccountLoginAsync',
    method: 'get',
    params: data
  })
}

export function getInfo(params) {
  return request({
    url: '/JwtAPI/AuthAsync/Me',
    method: 'post',
    data: params
  })
}

export const getUserByEnterpriseId = async data => {
  return request({
    url: `/JwtAPI/UserAsync/GetUserListByEnterprise`,
    method: 'get',
     params: data
  })
}

export const getUsers = params => {
  return request({
    url: '/JwtAPI/UserAsync/GetUserListsAsync',
    method: 'get',
    params: params
  })
}

export const getAllUsers = params => {
  return request({
    url: '/JwtAPI/UserAsync/GetAllUserListsAsync',
    method: 'get',
    params: params
  })
}

export const addUsers = data => {
  return request({
    url: '/JwtAPI/UserAsync/SubmitUserAsync',
    method: 'post',
    data
  })
}

//
export const getUserInfoById = id => {
  return request({
    url: `/JwtAPI/UserAsync/UserAsync?userId=${id}`,
    method: 'get',
  })
}

export const enable = (data) => {
  return request({
    url: "/JwtAPI/UserAsync/DisabledUserSwitchAsync",
    method: 'post',
    data
  })
}

export const changePassword = (data) => {
  return request({
    url: "/JwtAPI/UserAsync/ResetPasswordAsync",
    method: 'post',
    data
  })
}

export const changeOwnerPassword = (data) => {
  return request({
    url: "/JwtAPI/AuthAsync/Password",
    method: 'post',
    data
  })
}

export const getUserMenu = () => {
  return request({
    url: `/JwtAPI/AuthAsync/GetPermission?seriesId=eLabR_Middleground`,
    method: 'get',
  })
}

export const getUserButton = id => {
  return request({
    url: `/JwtAPI/AuthAsync/GetButtonPermission?menuId=${id}`,
    method: 'get',
  })
}

// 验证微信OpenID是否存在
export const userOpenIdIsExist = id => {
  return request({
    url: `/JwtAPI/User/UserOpenIdIsExist?Guid=${id}`,
    method: 'get',
  })
}

// 生成微信身份验证二维码 (根据Guid)
export const getQrUrlByGuid = id => {
  return request({
    url: `/JwtAPI/User/GetQrUrlByGuid?Guid=${id}`,
    method: 'get',
  })
}
//批量用户审核
export const ApprovalUserAsync = (data) => {
  return request({
    url: "/JwtAPI/UserAsync/ApprovalUserAsync",
    method: 'post',
    data
  })
}
//获取司机和押运员角色的用户列表(全部数据)（不分页）
export const GetAllUserLists = params => {
  return request({
    url: '/JwtAPI/UserAsync/GetAllUserLists',
    method: 'get',
    params: params
  })
}
